define(["scrollPhoto"],function (scrollPhoto) {
    /*单个分享的内容中部图片*/
    let sharePhoto = function (data) {
        this.timerOne = null
        this.pareNodeWidth = 0
        this.pointNode = document.createElement("div")
        this.pointNode.className = "share-photo"
        //判断是否是含有多张图
        if (data.images.length === 1) { //单张
            this.pointNode.innerHTML =
                '<img src="' + data.images[0].thumbUrl + '">'
        } else {//多张
            this.pointNode.innerHTML =
                '<div class="share-photo-inner">' +
                '<div class="share-photo-left">' +
                '<i class="fa fa-angle-left"></i>' +
                '</div>' +
                '<div class="share-photo-right">' +
                '<i class="fa fa-angle-right"></i>' +
                '</div>' +
                '<div class="share-photo-wrapper">' +
                '</div>' +
                '</div>'
        }
    }
    sharePhoto.prototype.setParentNode = function (length) {
        this.pareNodeWidth = length
    }
    //多张图片的轮播转动
    sharePhoto.prototype.setPhotoRoll = function (data, length) {
        if (data.images.length > 1) {
            this.setParentNode(length)
            let that = this,
                shareImgNode = {
                    pareNode: that.pointNode.querySelector(".share-photo-inner"),
                    pointNode: that.pointNode.querySelector(".share-photo-wrapper"),
                    pointLeft: that.pointNode.querySelector(".share-photo-left"),
                    pointRight: that.pointNode.querySelector(".share-photo-right"),
                },
                shareImgNodeLength = this.pareNodeWidth
            let personResult = new scrollPhoto(shareImgNode)
            personResult.setOnePhotoNode(that.setOneNode)
            personResult.init(shareImgNodeLength, data.images)
            personResult.resizeToWindow(true)
        }
    }
    sharePhoto.prototype.setPareWidth = function () {
        let that = this
        tool.on(window, "resize", function () {
            clearTimeout(that.timerOne)
            that.timerOne = setTimeout(function () {
                let width = that.pointNode.parentNode.parentNode.clientWidth
                that.pointNode.querySelector(".share-photo-inner").style.width = width + "px"
            })
        })
    }
    //设置单个节点
    sharePhoto.prototype.setOneNode = function (data) {
        return '<div class="share-photo-item item">\n' +
            '<div class="share-photo-item-img"><img src="' + data.thumb_path + '"></div>\n' +
            '</div>'
    }
    return sharePhoto
})